# 执行测试用例,生成测试报告
import os
import time
import unittest
import logging

from unittestreport import TestRunner

from config import BaseDir
import time

from common.logging_use import init_log_config
from config import BaseDir

init_log_config(BaseDir + f"/log/ihrm{time.strftime('%m-%d-%M')}.log")

suite = unittest.defaultTestLoader.discover("./scripts")
# suite = unittest.TestSuite()
logging.info("测试套件创建成功")

# suite.addTest(unittest.defaultTestLoader.discover("./scripts"))

# suite.addTest(unittest.makeSuite(TestIHRMLogin))
# logging.info("登录接口测试用例添加成功")

# suite.addTest(unittest.makeSuite(TestIhrmAdd))
# logging.info("添加员工接口测试用例添加成功")

# suite.addTest(unittest.makeSuite(TestDeptMan))
# logging.info("部门管理接口测试用例添加成功")

runner = TestRunner(suite, filename=f"ihrm_report{time.strftime('%m-%d-%M')}", report_dir=BaseDir + os.sep + "report",
                    templates=2)
runner.run()

# runner = HTMLTestReport(BaseDir + "/report/ihrm测试报告.html", "html_report",
#                         "此测试报告包含IHRM项目登录接口，员工添加及部门增删改查的测试用例执行情况。")
# runner.run(suite)
logging.info("测试报告生成成功")
